home *** CD-ROM | disk | FTP | other *** search
- {$M 65520,0,655360} {
-
- Vulkanus demo...... "My computer, My hero, My God, My life"
-
- PROJECTE: EUSKAL PARTY : " TUNGUSKA " By Skynet & Runner }
-
- Program TUNGUSKA;
-
- Uses Crt,Grflib,PasDVT; {Carregue la graph i el Vangelis Tracker}
-
- Const Tecta=0.017453292519943295769; {Operacions predisenyades}
- COST =0.999847695156391239157;
- SINT =0.017452406437283512819;
-
- MAXVERTEX=1000;
- MAXFACES=2000;
-
- Type TresD=Record
- X,Y,Z :extended;
- End;
- Graf =Record
- A,B,C:Integer;
- End;
-
- Var Cad,Arxiu:String;
- ASC:Text;
- Vertex,Poligons:String[4];
- Ver,Pol,code,i:Integer;
- VArray:Array [0..MAXVERTEX] of TresD;
- VPolig:Array [0..MAXFACES] of Graf;
- PV,p:Byte;
-
- { Procediments de Rotacio 3D--------------------------------------------- }
-
- Procedure Rotx(var Dades:Array of TresD);
- Var i : integer;
- Begin
- for i := 0 to MAXVERTEX do
- begin
- dades[i].y := dades[i].y * COST + dades[i].z * SINT;
- dades[i].z :=-dades[i].y * SINT + dades[i].z * COST;
- end;
- End;
-
- Procedure Roty(var dades:Array of TresD);
- Var i : integer;
- Begin
- For i := 0 to MAXVERTEX do
- Begin
- dades[i].x := dades[i].x * COST - dades[i].z * SINT;
- dades[i].z := dades[i].x * SINT + dades[i].z * COST;
- End;
- End;
-
- Procedure Rotz(var dades:Array of TresD);
- Var i : integer;
- Begin
- For i := 0 to MAXVERTEX do
- Begin
- dades[i].x := dades[i].x * COST + dades[i].y * SINT;
- dades[i].y :=-dades[i].x * SINT + dades[i].y * COST;
- End;
- End;
-
- {Procediments de carrega dels poligons i dels vertex------------------------}
-
- (* Millorar en un futur....algoritmes molt inexactes... *)
- Procedure Comproba_Vertex;
- Begin
- If vertex[2]=' ' then
- vertex:=' '+cad[21];
- If vertex[3]=' ' then
- vertex:=' '+cad[21]+cad[22];
- If vertex[4]=' ' then
- vertex:=' '+cad[21]+cad[22]+cad[23];
- If vertex[1]>' ' then
- poligons:=' '+cad[35]+cad[36];
- If Ord(Cad[0])>38 then Poligons:=Cad[36]+Cad[37]+Cad[38]+Cad[39]
- else Poligons:=Cad[36]+Cad[37]+Cad[38];
- If poligons[2]=' ' then
- poligons:=' '+cad[36];
- If poligons[3]=' ' then
- poligons:=' '+cad[36]+cad[37];
- If Poligons[4]=' ' then
- poligons:=' '+cad[36]+cad[37]+cad[38];
- End;
-
- Procedure Load_Vertex(Ver:Integer; Var VArray:Array of TresD);
- Var Cad:String;
- Value:String[4];
- I,J,K:Integer;
- Nombre:String[15];
- X:extended;
- Begin
- K:=0;
- Cad:=' ';
- Ver:=Ver-1; {El desfase es 1 perque comensa amb 0}
- Str(Ver,Value);
-
- While (Value<>Cad[8]+Cad[9]+Cad[10]) do
- Begin
- Readln(asc,Cad);
- if (Cad[1]='V') and (Cad[8]<>'l') then
- Begin
- I:=1;
- While Cad[i]+Cad[i+1]<>'X:' Do
- i:=i+1;
- i:=i+3; {Es per al espai en blanc}
- J:=1;
- Nombre:='00000000000000000';
- While ((Ord(Cad[i])>47) and (Ord(Cad[i])<58)) or
- (Cad[i]='-') or (Cad[i]='.') do
- Begin
- Nombre[j]:=Cad[i];
- J:=j+1;
- i:=i+1;
- End;
- For i:=j to 15 do
- Nombre[i]:='0';
- Val(Nombre,x,code);
- if x<>0.0 then VArray[k].x:=x else VArray[k].x:=0.00001;
- While Cad[i]+Cad[i+1]<>'Y:' Do
- i:=i+1;
- i:=i+3; {Es per al espai en blanc}
- J:=1;
- Nombre:='00000000000000000';
- While ((Ord(Cad[i])>47) and (Ord(Cad[i])<58)) or
- (Cad[i]='-') or (Cad[i]='.') do
- Begin
- Nombre[j]:=Cad[i];
- J:=j+1;
- i:=i+1;
- End;
- For i:=j to 15 do
- Nombre[i]:='0';
- Val(Nombre,x,code);
- if x<>0.0 then VArray[k].y:=x else VArray[k].y:=0.00001;
- While Cad[i]+Cad[i+1]<>'Z:' Do
- i:=i+1;
- i:=i+3; {Es per al espai en blanc}
- J:=1;
- Nombre:='00000000000000000';
- While ((Ord(Cad[i])>47) and (Ord(Cad[i])<58)) or
- (Cad[i]='-') or (Cad[i]='.') do
- Begin
- Nombre[j]:=Cad[i];
- J:=j+1;
- i:=i+1;
- End;
- For i:=j to 15 do
- Nombre[i]:='0';
- Val(Nombre,x,code);
- if x<>0.0 then VArray[k].z:=x else VArray[k].z:=0.00001;
- K:=k+1;
- End;
- End;
-
- End;
-
- Procedure Load_Poligon(Pol:Integer; Var Vpolig:Array of Graf);
- Var I,J,K:Integer;
- Cad:String;
- Tex:String[4];
- Valor:extended;
-
- Begin
- I:=1;
- J:=1;
- K:=0;
- Cad:=' ';
- While Cad<>'Face list:' do
- Readln(ASC,Cad);
- Readln(ASC,Cad);
- While K<>(pol) do
- Begin
- If (Cad[1]='F') and (Cad[4]='e') then
- Begin
- While Cad[i]+Cad[i+1]<>'A:' do
- I:=i+1;
- I:=I+2;
- tex:=' ';
- While ((Ord(Cad[i])>47) and (Ord(Cad[i])<58)) do
- Begin
- Tex[j]:=Cad[i];
- i:=i+1;
- j:=j+1;
- End;
- If (Tex[2]=' ') and (Tex[3]=' ') and (Tex[4]=' ') then
- Begin
- Tex[4]:=Tex[1];
- Tex[3]:=' ';
- Tex[2]:=' ';
- Tex[1]:=' ';
- End;
- If (Tex[3]=' ') and (Tex[4]=' ') then
- Begin
- Tex[4]:=Tex[2];
- Tex[3]:=Tex[1];
- Tex[2]:=' ';
- Tex[1]:=' ';
- End;
- If tex[4]=' ' then
- Begin
- Tex[4]:=Tex[3];
- Tex[3]:=Tex[2];
- Tex[2]:=Tex[1];
- Tex[1]:=' ';
- End;
-
- Val(Tex,Valor,Code);
- Vpolig[k].A:=round(Valor);
- I:=10;
- j:=1;
- While Cad[i]+Cad[i+1]<>'B:' do
- I:=i+1;
- I:=I+2;
- tex:=' ';
- While ((Ord(Cad[i])>47) and (Ord(Cad[i])<58)) do
- Begin
- Tex[j]:=Cad[i];
- i:=i+1;
- j:=j+1;
- End;
- If (Tex[2]=' ') and (Tex[3]=' ') and (Tex[4]=' ') then
- Begin
- Tex[4]:=Tex[1];
- Tex[3]:=' ';
- Tex[2]:=' ';
- Tex[1]:=' ';
- End;
- If (Tex[3]=' ') and (Tex[4]=' ') then
- Begin
- Tex[4]:=Tex[2];
- Tex[3]:=Tex[1];
- Tex[2]:=' ';
- Tex[1]:=' ';
- End;
- If tex[4]=' ' then
- Begin
- Tex[4]:=Tex[3];
- Tex[3]:=Tex[2];
- Tex[2]:=Tex[1];
- Tex[1]:=' ';
- End;
-
- Val(Tex,Valor,Code);
- Vpolig[k].B:=round(Valor);
- I:=15;
- j:=1;
- While Cad[i]+Cad[i+1]<>'C:' do
- I:=i+1;
- I:=I+2;
- tex:=' ';
- While ((Ord(Cad[i])>47) and (Ord(Cad[i])<58)) do
- Begin
- Tex[j]:=Cad[i];
- i:=i+1;
- j:=j+1;
- End;
- If (Tex[2]=' ') and (Tex[3]=' ') and (Tex[4]=' ') then
- Begin
- Tex[4]:=Tex[1];
- Tex[3]:=' ';
- Tex[2]:=' ';
- Tex[1]:=' ';
- End;
- If (Tex[3]=' ') and (Tex[4]=' ') then
- Begin
- Tex[4]:=Tex[2];
- Tex[3]:=Tex[1];
- Tex[2]:=' ';
- Tex[1]:=' ';
- End;
- If tex[4]=' ' then
- Begin
- Tex[4]:=Tex[3];
- Tex[3]:=Tex[2];
- Tex[2]:=Tex[1];
- Tex[1]:=' ';
- End;
-
- Val(Tex,Valor,Code);
- Vpolig[k].C:=round(Valor);
- K:=k+1;
- End;
- readln(ASC,Cad);
- readln(ASC,Cad);
- I:=10;
- J:=1;
- Tex:=' ';
- End;
- End;
-
- { Dibuixa tots els poligons que conte el objecte ----------------------------}
-
-
- Procedure Draw_3d(Varray:Array of TresD;Vpolig:Array of graf;
- c,pv:byte;origeX,origeY,pol:Integer);
-
-
- Procedure lines(x1, y1, x2, y2: extended;c,pv:byte;origeX,OrigeY:integer);
- Begin
- fLinea(round(x1) + origeX,round(y1) + origeY,round(x2) + origeX,round(y2) + origeY,c,PV);
- End;
-
- Var I:integer;
-
- Begin
- For I:=0 to (pol-1) do
- Begin
- lines(Varray[Vpolig[I].a].X,Varray[Vpolig[I].a].y,Varray[Vpolig[i].b].X,
- Varray[Vpolig[i].b].y,c,pv,origex,origey);
- lines(Varray[Vpolig[I].b].X,Varray[Vpolig[I].b].y,Varray[Vpolig[i].c].X,
- Varray[Vpolig[i].c].y,c,pv,origex,origey);
- lines(Varray[Vpolig[I].c].X,Varray[Vpolig[I].c].y,Varray[Vpolig[i].a].X,
- Varray[Vpolig[i].a].y,c,pv,origex,origey);
- End
- End;
-
- Procedure Increment(Var Varray:Array of TresD;n:extended);
- Var I:integer;
- Begin
- For I:=0 to 660 do
- Begin
- Varray[i].x:=(Varray[i].x/100)*n;
- Varray[i].y:=(Varray[i].y/100)*n;
- Varray[i].z:=(Varray[i].z/100)*n;
- End;
- End;
-
- Function existeix(s:string):boolean;
- Var f:file;
- Begin
- {$I-}
- assign(f,s);
- reset(f);
- close(f);
- {$I+}
- existeix:=(IOResult=0) and (s <>'');
- End;
-
- {-------------------------------Programa Principal---------------------------}
-
-
- BEGIN
- {OUTPUT-----------------------------------}
-
- ClrScr;
- TextBackground(Blue);
- Writeln('3D Vulkanus. PROJECTE TUNGUSKA. By Skynet');
- TextBackground(Black);
- Writeln;
- Writeln;
-
- repeat
- writeln('Introdueix el nom i extensio i la ruta del arxiu.(Q per eixir)');
- readln(arxiu);
- if not existeix(arxiu) then
- Writeln('ERROR! El arxiu introduit no existeix.');
- until existeix(arxiu) or (arxiu='q') or (arxiu='Q');
- if (arxiu='q') or (arxiu='Q') then
- halt(27);
-
- {-----------------Programa----------------}
-
- { IF NOT VT_Init THEN
- BEGIN
- WriteLn('Driver no detectat! Si continues, no obtindras musica...');
- readln;
- END;
-
- {ENTORN DEL VANGELIS TRACKER-------Llegir intruccions}
-
- { VT_GoTo(1, 1);
- VT_Autoon;
- VT_SetVolume(255);
- VT_Start;
- VT_SyncStart;
-
- {ALGORITMES ARXIUS------------------------------------}
-
- Assign(ASC,Arxiu);
- reset(ASC);
- Cad:='';
- While (Cad[1]<>'T') and (Cad[6]<>'e') do
- readln(asc,Cad);
- Vertex :=Cad[21]+Cad[22]+Cad[23]+Cad[24];
-
- COMPROBA_VERTEX;
-
- Val(Vertex,Ver,code);
- Val(Poligons,pol,code);
- Load_Vertex (Ver,VArray);
- Load_Poligon(Pol,VPolig);
- Close(ASC);
-
- {ALGORITMES GRAFICS-----------------------------------}
-
- ModoGrafico;
- PV:=CreaVirtual;
- fBorraPantalla(0,0);
- fBorraPantalla(0,PV);
-
- Increment(Varray,40.0);
-
- repeat
- draw_3d(VArray,Vpolig,1,pv,160,100,pol);
- CopiaPantalla(PV,0);
- rotx(Varray);
- roty(Varray);
- rotz(Varray);
- increment(Varray,100.034);
- fborrapantalla(0,pv);
- until keypressed;
-
- Fadedown(20000,1,0);
-
- {For p:=VT_GetVolume downto 0 do
- Begin
- VT_Setvolume(p);
- delay(3);
- End;}
-
- ModoTexto;
- VT_AutoOff;
- VT_Abort;
-
- END.
-
-